package com.sinoglobal.ningxia.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sinoglobal.ningxia.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by XINDZ on 2017/2/15.
 * 功能:直播预告的Adapter
 */

public class ProgramDayAdapter extends BaseAdapter {
    private LayoutInflater mInflater;
    List foreShowtList = new ArrayList();
    Context context;

    public void setForeShowtList(List foreShowtList) {
        this.foreShowtList = foreShowtList;
        notifyDataSetChanged();
    }

    public ProgramDayAdapter(Context context) {
        this.context = context;
        mInflater = LayoutInflater.from(context);
    }

    public ProgramDayAdapter(Context context, List foreShowtList) {
        this.context = context;
        this.foreShowtList = foreShowtList;
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return foreShowtList.size();
    }

    @Override
    public Object getItem(int i) {
        return foreShowtList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        final Holder holder;
        if (view == null) {
            holder = new Holder();
            view = mInflater.inflate(R.layout.item_foreshow, null);
            holder.tv_foreshow_title = (TextView) view.findViewById(R.id.tv_foreshow_title);
            holder.tv_foreshow_intro = (TextView) view.findViewById(R.id.tv_foreshow_intro);
            holder.tv_foreshow_date = (TextView) view.findViewById(R.id.tv_foreshow_date);
            view.setTag(holder);
        } else {
            holder = (Holder) view.getTag();
        }
        String title = (String) foreShowtList.get(i);
        holder.tv_foreshow_title.setText(title);

        return view;
    }


    static class Holder {
        public TextView tv_foreshow_title, tv_foreshow_intro, tv_foreshow_date;

    }
}
